public class Main {

    static class Solution{
        public void rotate(int[] nums , int k){
            int n = nums.length;
            int[] newNums = nums.clone();
            for(int i = 0 ; i < n ; i++) {
                nums[(i + k) % n] = newNums[i];
            }
        }
    }

    public static void main(String[] args) {
        int [] nums = new int[]{1,2,3,4,5,6,7,8,9};
        Solution solution = new Solution();
        solution.rotate(nums , 3);
        for (int num : nums) {
            System.out.print(num + " ");
        }
    }
}